/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import Matrix from './Matrix';
let count = 1000;
let count1 = 10;
let count2=10000;
let count3=30000;
function constructWithCopy_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[40., 50., 60., 23, 13], [70., 80., 10., 5, 3], [7., 21., 15, 2, 32], [2, 9, 10., 32, 3], [5., 2, 10., 15, 53]];
    A = new Matrix(array);
    let s = Date.now();
    B = Matrix.constructWithCopy(array);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_constructWithCopy(5*5): ${ave} ms`);
  if (A.m !== B.m || A.n !== B.n) {
    throw new Error('Matrix_constructWithCopy err');
  }
  // print(JSON.stringify(B))
  // {"A":[[40,50,60,23,13],[70,80,10,5,3],[7,21,15,2,32],[2,9,10,32,3],[5,2,10,15,53]],"m":5,"n":5}
}

function constructWithCopy_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 100; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = Matrix.constructWithCopy(array);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_constructWithCopy(100*100): ${ave} ms`);
  if (A.m !== B.m || A.n !== B.n) {
    throw new Error('Matrix_constructWithCopy err');
  }
  // print(JSON.stringify(B))
}
function copy_test() {
  let sumAve = 0;
  let A;
  let copy;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[411., 123., 161., 2, 23], [12., 13., 61., 62, 93], [41., 13., 11, 82, 223], [71., 19., 161., 72, 23], [81., 63., 31., 42, 23]];
    A = new Matrix(array);
    let s = Date.now();
    copy = A.copy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_copy(5*5): ${ave} ms`);
  if (A.m !== copy.m || A.n !== copy.n) {
    throw new Error('Matrix_copy  err');
  }
  // print(JSON.stringify(copy))
  //{"A":[[411,123,161,2,23],[12,13,61,62,93],[41,13,11,82,223],[71,19,161,72,23],[81,63,31,42,23]],"m":5,"n":5}

}
function copy_test_01() {
  let sumAve = 0;
  let A;
  let copy;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 100; i++) {
    A = new Matrix(array);
    let s = Date.now();
    copy = A.copy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_copy(100*100): ${ave} ms`);
  if (A.m !== copy.m || A.n !== copy.n) {
    throw new Error('Matrix_copy  err');
  }
}

function clone_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[16., 22., 223, 9, 43], [50., 55., 19., 24, 21], [30., 155., 119., 243, 221], [502., 155., 139., 24, 221], [520., 525., 129., 224, 621]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.clone();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_clone(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[16,22,223,9,43],[50,55,19,24,21],[30,155,119,243,221],[502,155,139,24,221],[520,525,129,224,621]],"m":5,"n":5}') {
    throw new Error('Matrix_clone  err');
  }
  // print(JSON.stringify(B))
  //{"A":[[16,22,223,9,43],[50,55,19,24,21],[30,155,119,243,221],[502,155,139,24,221],[520,525,129,224,621]],"m":5,"n":5}
}

function clone_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 100; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.clone();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_clone(100*100): ${ave} ms`);
  if (A.m !== B.m || A.n !== B.n) {
    throw new Error('Matrix_clone  err');
  }

}

function getArray_test() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 300000; i++) {
    array = [[24., 3, 14, 5., 16.], [711., 38., 90., 23, 53], [16, 22, 223, 9, 43], [50, 55, 19, 24, 21], [30, 155, 119, 243, 221]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getArray();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getArray(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '[[24,3,14,5,16],[711,38,90,23,53],[16,22,223,9,43],[50,55,19,24,21],[30,155,119,243,221]]') {
    throw new Error('Matrix_getArray err');
  }
  // print(JSON.stringify(B))
  //[[24,3,14,5,16],[711,38,90,23,53],[16,22,223,9,43],[50,55,19,24,21],[30,155,119,243,221]]

}
function getArray_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 300000; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.getArray();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getArray(100*100): ${ave} ms`);
  if (Array.isArray(B) !== true) {
    throw new Error('Matrix_getArray err');
  }

}

function getArrayCopy_test() {
  let sumAve = 0;
  let A;
  let getArrayCopy;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[100., 120., 63, 42, 3], [423., 15., 34, 58, 62.], [7., 28., 110., 52, 75], [711., 38., 90., 23, 53], [16, 22, 223, 9, 43]];
    A = new Matrix(array);
    let s = Date.now();
    getArrayCopy = A.getArrayCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getArrayCopy(5*5): ${ave} ms`);
  if (JSON.stringify(getArrayCopy) !== '[[100,120,63,42,3],[423,15,34,58,62],[7,28,110,52,75],[711,38,90,23,53],[16,22,223,9,43]]') {
    throw new Error('Matrix_getArrayCopy err');
  }
  // print(JSON.stringify(getArrayCopy))
  // [[100,120,63,42,3],[423,15,34,58,62],[7,28,110,52,75],[711,38,90,23,53],[16,22,223,9,43]]
}

function getArrayCopy_test_01() {
  let sumAve = 0;
  let A;
  let getArrayCopy;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 100; i++) {
    A = new Matrix(array);
    let s = Date.now();
    getArrayCopy = A.getArrayCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getArrayCopy(100*100): ${ave} ms`);
  if (Array.isArray(getArrayCopy) !== true) {
    throw new Error('Matrix_getArrayCopy  err');
  }
}
//按列拉平成一维数组
function getColumnPackedCopy_test() {
  let sumAve = 0;
  let A;
  let getColumnPackedCopy;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[41., 25., 31, 44, 93], [24., 35., 16., 32, 34], [73., 83., 100., 37, 31], [423, 15, 34, 58, 62], [7, 28, 110, 52, 75]];
    A = new Matrix(array);
    let s = Date.now();
    getColumnPackedCopy = A.getColumnPackedCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;

  print(`Matrix_getColumnPackedCopy(5*5): ${ave} ms`);
  if (JSON.stringify(getColumnPackedCopy) !== '[41,24,73,423,7,25,35,83,15,28,31,16,100,34,110,44,32,37,58,52,93,34,31,62,75]') {
    throw new Error('Matrix_getColumnPackedCopy err');
  }
  // print(JSON.stringify(getColumnPackedCopy));
  //[41,24,73,423,7,25,35,83,15,28,31,16,100,34,110,44,32,37,58,52,93,34,31,62,75]
}
function getColumnPackedCopy_test_01() {
  let sumAve = 0;
  let A;
  let getColumnPackedCopy;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }

  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    getColumnPackedCopy = A.getColumnPackedCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;

  print(`Matrix_getColumnPackedCopy(100*100): ${ave} ms`);
  if (Array.isArray(getColumnPackedCopy) !== true) {
    throw new Error('Matrix_getColumnPackedCopy  err');
  }
}

function getRowPackedCopy_test() {
  let sumAve = 0;
  let A;
  let getRowPackedCopy;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[10., 21., 10., 254, 64], [18., 28., 233, 32, 74], [15., 21., 31, 23, 88], [16., 22., 223, 9, 43], [50., 55., 19., 24, 21]];
    A = new Matrix(array);
    let s = Date.now();
    getRowPackedCopy = A.getRowPackedCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getRowPackedCopy(5*5): ${ave} ms`);
  if (JSON.stringify(getRowPackedCopy) !== '[10,21,10,254,64,18,28,233,32,74,15,21,31,23,88,16,22,223,9,43,50,55,19,24,21]') {
    throw new Error('Matrix_getRowPackedCopy err');
  }
  // print(JSON.stringify(getRowPackedCopy));
  // [10,21,10,254,64,18,28,233,32,74,15,21,31,23,88,16,22,223,9,43,50,55,19,24,21]

}

function getRowPackedCopy_test_01() {
  let sumAve = 0;
  let A;
  let getRowPackedCopy;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    getRowPackedCopy = A.getRowPackedCopy();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getRowPackedCopy(100*100): ${ave} ms`);
  if (Array.isArray(getRowPackedCopy) !== true) {
    throw new Error('Matrix_getRowPackedCopy  err');
  }
}

function getRowDimension_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 300000; i++) {
    array = [[16., 42., 37, 23, 32], [45., 25., 86., 21, 36], [27., 48., 80., 37, 67], [18., 28., 233, 32, 74], [15., 21., 31, 23, 88]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getRowDimension();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_getRowDimension(5*5): ${ave} ms`);
  if (B !== 5) {
    throw new Error('Matrix_getRowDimension err');
  }
}

function getRowDimension_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 300000; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.getRowDimension();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_getRowDimension(100*100): ${ave} ms`);
  if (B !== 100) {
    throw new Error('Matrix_getRowDimension err');
  }
}


function getMatrix$int$int$int$int_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[24., 35., 67, 4, 6.], [7., 42, 7, 38., 140.], [57., 34., 2., 67, 26], [16., 42., 37, 23, 32], [45., 25., 86., 21, 36]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix$int$int$int$int(0, 3, 1, 4);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int$int$int$int(5*5): ${ave} ms`);
  if (B.m !== 4 || B.n !== 4) {
    throw new Error('Matrix_getMatrix$int$int$int$int err');
  }
  // print(JSON.stringify(B))//{"A":[[35,67,4,6],[42,7,38,140],[34,2,67,26],[42,37,23,32]],"m":4,"n":4}
}

function getMatrix$int$int$int$int_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[24., 35., 67, 4, 6.], [7., 42, 7, 38., 140.], [57., 34., 2., 67, 26], [16., 42., 37, 23, 32], [45., 25., 86., 21, 36]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix$int$int$int$int(0, 3, 1, 4);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int$int$int$int(100*100): ${ave} ms`);
  if (B.m !== 4 || B.n !== 4) {
    throw new Error('Matrix_getMatrix$int$int$int$int err');
  }
}

function setMatrix$int$int$int$int$Jama_Matrix_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count2; i++) {
    array = [[15., 12., 76, 3, 53], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310], [43, 45, 32, 56, 76], [27., 38., 50., 32, 56]];
    array2 = [[32., 333, 89, 34, 20], [40., 432., 1., 5, 23], [32., 23., 11., 42, 56], [16, 42, 37, 23, 32], [45., 25., 86., 21, 36]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int$int$int$int$Jama_Matrix(1, 2, 0, 2, C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_setMatrix$int$int$int$int$Jama_Matrix(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[15,12,76,3,53],[32,333,89,21,65],[40,432,1,67,310],[43,45,32,56,76],[27,38,50,32,56]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix$int$int$int$int$Jama_Matrix  err');
  }
  // print(JSON.stringify(A))
  //{"A":[[15,12,76,3,53],[32,333,89,21,65],[40,432,1,67,310],[43,45,32,56,76],[27,38,50,32,56]],"m":5,"n":5}
}

function setMatrix$int$int$int$int$Jama_Matrix_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count3; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int$int$int$int$Jama_Matrix(1, 2, 0, 2, C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_setMatrix$int$int$int$int$Jama_Matrix(100*100): ${ave} ms`);
  if (A.m !== 10 || A.n !== 10) {
    throw new Error('Matrix_setMatrix$int$int$int$int$Jama_Matrix  err');
  }
}

function setMatrix$int_A$int_A$Jama_Matrix_test() {
  let sumAve = 0;
  let A;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count3; i++) {
    array = [[12, 53, 21, 22., 33], [43, 18, 34, 53, 56.], [85, 4, 53, 38, 42.], [32., 333, 89, 34, 20], [40., 432., 1., 5, 23]];
    array2 = [[3, 7, 32, 13., 43], [12., 50, 86, 45, 4.], [70., 56., 98, 36, 43], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int_A$int_A$Jama_Matrix([0, 3], [0, 2], C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix$int_A$int_A$Jama_Matrix(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[3,53,7,22,33],[43,18,34,53,56],[85,4,53,38,42],[12,333,50,34,20],[40,432,1,5,23]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix$int_A$int_A$Jama_Matrix err');
  }
  // print(JSON.stringify(A))
  // {"A":[[3,53,7,22,33],[43,18,34,53,56],[85,4,53,38,42],[12,333,50,34,20],[40,432,1,5,23]],"m":5,"n":5}
}

function setMatrix$int_A$int_A$Jama_Matrix_test_01() {
  let sumAve = 0;
  let A;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count3; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int_A$int_A$Jama_Matrix([0, 3], [0, 2], C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix$int_A$int_A$Jama_Matrix(100*100): ${ave} ms`);
  if (A.m !== 10 || A.n !== 10) {
    throw new Error('Matrix_setMatrix$int_A$int_A$Jama_Matrix  err');
  }
}

function setMatrix$int_A$int$int$Jama_Matrix_test() {
  let sumAve = 0;
  let A;
  let C;
  let array;
  let array2 = [];
  for (let i = 0; i < count3*2; i++) {
    array = [[113., 32., 513, 3, 24], [14., 152., 161., 223, 32], [41., 25., 68., 34, 45], [78., 89., 98., 37, 74], [12, 333, 50, 34, 20]];
    array2 = [[452., 13., 330, 32, 11], [21., 321., 1211., 78, 44], [63., 42., 1., 23, 67], [70., 13., 112., 321, 12], [40, 432, 14, 5, 23]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int_A$int$int$Jama_Matrix([0, 2], 1, 2, C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix$int_A$int$int$Jama_Matrix(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[113,452,13,3,24],[14,152,161,223,32],[41,21,321,34,45],[78,89,98,37,74],[12,333,50,34,20]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix$int_A$int$int$Jama_Matrix err');
  }
  // print(JSON.stringify(A))
  // {"A":[[113,452,13,3,24],[14,152,161,223,32],[41,21,321,34,45],[78,89,98,37,74],[12,333,50,34,20]],"m":5,"n":5}
}

function setMatrix$int_A$int$int$Jama_Matrix_test_01() {
  let sumAve = 0;
  let A;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count3; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int_A$int$int$Jama_Matrix([0, 2], 1, 2, C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix$int_A$int$int$Jama_Matrix(100*100): ${ave} ms`);
  if (A.m !== 10 || A.n !== 10) {
    throw new Error('Matrix_setMatrix$int_A$int$int$Jama_Matrix err');
  }
  // print(JSON.stringify(A))
  // {"A":[[113,452,13,3,24],[14,152,161,223,32],[41,21,321,34,45],[78,89,98,37,74],[12,333,50,34,20]],"m":5,"n":5}
}

function setMatrix$int$int$int_A$Jama_Matrix_test() {
  let sumAve = 0;
  let A;
  let C;
  let array;
  let array2 = [];
  for (let i = 0; i < count3; i++) {
    array = [[12., 34., 123, 3, 57], [94., 5., 42., 33, 21], [125., 82., 10, 53, 13], [14, 152, 161, 223, 32], [41, 21, 321, 34, 45]];
    array2 = [[42., 12., 23, 24, 65], [14, 425, 2, 36, 35], [17., 87., 160., 35, 42], [41., 25., 68., 34, 45], [78., 89., 98., 37, 74]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int$int$int_A$Jama_Matrix(0, 3, [0, 4], C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_setMatrix$int$int$int_A$Jama_Matrix(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[42,34,123,3,12],[14,5,42,33,425],[17,82,10,53,87],[41,152,161,223,25],[41,21,321,34,45]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix$int$int$int_A$Jama_Matrix err');
  }
  // print(JSON.stringify(A))
  // {"A":[[42,34,123,3,12],[14,5,42,33,425],[17,82,10,53,87],[41,152,161,223,25],[41,21,321,34,45]],"m":5,"n":5}
}

function setMatrix$int$int$int_A$Jama_Matrix_test_01() {
  let sumAve = 0;
  let A;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count3; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.setMatrix$int$int$int_A$Jama_Matrix(0, 3, [0, 4], C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_setMatrix$int$int$int_A$Jama_Matrix(100*100): ${ave} ms`);
  if (A.m !== 10 || A.n !== 10) {
    throw new Error('Matrix_setMatrix$int$int$int_A$Jama_Matrix err');
  }
  // print(JSON.stringify(A))
  // {"A":[[42,34,123,3,12],[14,5,42,33,425],[17,82,10,53,87],[41,152,161,223,25],[41,21,321,34,45]],"m":5,"n":5}
}


function set_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count3; i++) {
    array = [[21., 3, 423, 72., 83], [43., 45, 32, 56., 76.], [27., 38., 50., 32, 56], [57., 34., 2., 67, 26], [16., 42., 37, 23, 32]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.set(0, 1, 66);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_set(5*5): ${ave} ms`);
  if (A.getArray()[0][1] !== 66) {
    throw new Error('Matrix_set err');
  }
  // print(JSON.stringify(A))
  // {"A":[[21,66,423,72,83],[43,45,32,56,76],[27,38,50,32,56],[57,34,2,67,26],[16,42,37,23,32]],"m":5,"n":5}
  // print(A.getArray()[0][1] == 66)
}
function set_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 300000; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.set(0, 1, 66);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_set(100*100): ${ave} ms`);
  if (A.getArray()[0][1] !== 66) {
    throw new Error('Matrix_set err');
  }
  // print(JSON.stringify(A))
  // print(A.getArray()[0][1] == 66)
}
//置换行列颠倒
function transpose_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[135., 22., 23, 67, 21], [14., 52., 36, 56, 85], [71., 38., 123, 564, 21], [14, 5, 42, 33, 425], [17, 82, 10, 53, 87]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.transpose();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_transpose(5*5): ${ave} ms`);
  if (B.getArray()[0][1] !== A.getArray()[1][0]) {
    throw new Error('Matrix_transpose  err');
  }
  // print(JSON.stringify(A))
  // {"A":[[135,22,23,67,21],[14,52,36,56,85],[71,38,123,564,21],[14,5,42,33,425],[17,82,10,53,87]],"m":5,"n":5}
  // print(JSON.stringify(B))
  // {"A":[[135,14,71,14,17],[22,52,38,5,82],[23,36,123,42,10],[67,56,564,33,53],[21,85,21,425,87]],"m":5,"n":5}
}

function transpose_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.transpose();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_transpose(100*100): ${ave} ms`);
  if (B.getArray()[0][1] !== A.getArray()[1][0]) {
    throw new Error('Matrix_transpose  err');
  }
}

// 返回列之和的最大值
function norm1_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[37., 18., 910., 32, 343], [43., 135., 3., 21, 34], [716., 183., 9., 32, 12], [14., 52., 36, 56, 85], [71., 38., 123, 564, 21]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.norm1();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_norm1(5*5): ${ave} ms`)
  if (B !== 1081) {
    throw new Error('Matrix_norm1 err')
  }
}

function norm1_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.norm1();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_norm1(100*100): ${ave} ms`)
  // print(B)
  if (typeof (B) !== 'number') {
    throw new Error('Matrix_norm1 err')
  }
}

//返回最大奇异值
function norm2_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[154., 42., 354, 33, 31], [73., 83., 134, 5, 43], [43., 135., 3., 21, 34], [716., 183., 9., 32, 12], [14., 52., 36, 56, 85]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.norm2();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_norm2(5*5): ${ave} ms`);
  // if (B !== 776.479171116998) {
  //   throw new Error('Matrix_norm2 err');
  // }
}

// 计算矩阵行之和的最大值
function normInf_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[12., 22., 13, 32, 42], [54., 45., 26., 32, 21], [27., 28., 32., 21, 45], [154., 42., 354, 33, 31], [73., 83., 134, 5, 43]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.normInf();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_normInf(5*5): ${ave} ms`)
  if (B !== 614) {
    throw new Error('Matrix_normInf err')
  }
}
function normInf_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 100; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.normInf();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_normInf(100*100): ${ave} ms`)
  if (typeof (B) !== 'number') {
    throw new Error('Matrix_normInf err')
  }
}
//对矩阵类所有的个数先平方加在一起在开方
function normF_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    array = [[12., 22., 13, 2, 32], [54., 45., 26., 32, 54], [27., 28., 32., 32, 11], [54., 45., 26., 32, 21], [27., 28., 32., 21, 45]];
    A = new Matrix(array);
    B = A.normF();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_normF(5*5): ${ave} ms`);
  // print(JSON.stringify(B))//164.76953601925328
  if (JSON.stringify(B) !== '164.76953601925328') {
    throw new Error('Matrix_normF err');
  }
}

function normF_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.normF();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_normF(100*100): ${ave} ms`);
  if (typeof (B) !== 'number') {
    throw new Error('Matrix_normF err');
  }
}

//将矩阵取反
function uminus_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[324, 35, -326, 23, 55], [7, 38, 310, -24, 5], [54, -45, 26, 34, 97], [12, 22, 13, 2, 322], [34, 45, 26, 32, 54]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.uminus();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_uminus(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[-324,-35,326,-23,-55],[-7,-38,-310,24,-5],[-54,45,-26,-34,-97],[-12,-22,-13,-2,-322],[-34,-45,-26,-32,-54]],"m":5,"n":5}') {
    throw new Error('Matrix_uminus err');
  }
  // print(JSON.stringify(B))
  //{"A":[[-324,-35,326,-23,-55],[-7,-38,-310,24,-5],[-54,45,-26,-34,-97],[-12,-22,-13,-2,-322],[-34,-45,-26,-32,-54]],"m":5,"n":5}
}

function uminus_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    let s = Date.now();
    A = new Matrix(array);
    B = A.uminus();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_uminus(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_uminus err');
  }
  // print(JSON.stringify(B))
  //{"A":[[-324,-35,326,-23,-55],[-7,-38,-310,24,-5],[-54,45,-26,-34,-97],[-12,-22,-13,-2,-322],[-34,-45,-26,-32,-54]],"m":5,"n":5}
}

//两个矩阵和并
function plus_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < count; i++) {
    array = [[14., 35., 36., 32, 56], [74., 48., 410., 31, 23], [12., 38., 310., 32, 14], [54., 45., 26., 32, 54], [27., 28., 32., 32, 11]];
    array2 = [[223., 112., 313, 43, 2], [43., 54., 62., 75, 32], [7., 37., 21., 22, 45], [154., 42., 354, 33, 31], [73., 83., 134, 5, 43]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.plus(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_plus(5*5): ${ave} ms`);
  if (B.getArray()[0][0] !== array[0][0] + array2[0][0]) {
    throw new Error('Matrix_plus err');
  }
  // print(JSON.stringify(B))
  //{"A":[[237,147,349,75,58],[117,102,472,106,55],[19,75,331,54,59],[208,87,380,65,85],[100,111,166,37,54]],"m":5,"n":5}
  // expect(B.getArray()[0][0]).assertEqual(array[0][0] + array2[0][0])
}
function plus_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now()
    B = A.plus(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_plus(100*100): ${ave} ms`);
  if (B.getArray()[0][0] !== array[0][0] + array2[0][0]) {
    throw new Error('Matrix_plus err');
  }
}


function plusEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 10000; i++) {
    array = [[71., 38., 344, 32, 3], [23., 4., 13, 36, 8], [24., 183., 130., 321, 45], [43., 54., 62., 75, 32], [7., 37., 21., 22, 45]];
    array2 = [[117., 84., 230., 5, 62], [23., 12., 9, 7, 2], [37., 34., 5., 34, 23], [12., 38., 310., 32, 14], [54., 45., 26., 32, 54]];

    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.plusEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_plusEquals(5*5): ${ave} ms`);
  if (A.n !== 5) {
    throw new Error('Matrix_plusEquals err');
  }
  // print(JSON.stringify(A),'A')
  // {"A":[[188,122,574,37,65],[46,16,22,43,10],[61,217,135,355,68],[55,92,372,107,46],[61,82,47,54,99]],"m":5,"n":5
}
function plusEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 100; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.plusEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_plusEquals(100*100): ${ave} ms`);
  if (A.n !== 100) {
    throw new Error('Matrix_plusEquals err');
  }
  // print(JSON.stringify(A),'A')
  // {"A":[[188,122,574,37,65],[46,16,22,43,10],[61,217,135,355,68],[55,92,372,107,46],[61,82,47,54,99]],"m":5,"n":5
}
//两个矩阵之差A.minus(C);  A-C
function minus_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[42., 32., 43, 6, 435], [27., 118., 120., 43, 31], [11., 351., 43., 34, 42], [46, 16, 22, 43, 10], [61, 217, 135, 355, 68]];
    array2 = [[12., 22., 45, 4, 23], [14., 12., 116., 32, 44], [7., 41., 10., 4, 33], [55, 92, 372, 107, 46], [61, 82, 47, 54, 99]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.minus(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_minus(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[30,10,-2,2,412],[13,106,4,11,-13],[4,310,33,30,9],[-9,-76,-350,-64,-36],[0,135,88,301,-31]],"m":5,"n":5}') {
    throw new Error('Matrix_minus err');
  }
  // print(JSON.stringify(B))
  // {"A":[[30,10,-2,2,412],[13,106,4,11,-13],[4,310,33,30,9],[-9,-76,-350,-64,-36],[0,135,88,301,-31]],"m":5,"n":5}

}

function minus_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.minus(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_minus(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_minus err');
  }

}

//两个矩阵之差A.minusEquals(C);  A-C
function minusEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < 10000; i++) {
    array = [[732., 138., 130., 56, 77], [112., 32., 45, 47, 54], [27., 34., 254., 65, 36], [42., 32., 43, 6, 435], [27., 118., 120., 43, 31]];
    array2 = [[27., 38., 310., 23, 45], [232., 62., 55, 26, 34], [42., 11., 24., 43, 24], [12., 22., 45, 4, 23], [14., 12., 116., 32, 44]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.minusEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_minusEquals(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[705,100,-180,33,32],[-120,-30,-10,21,20],[-15,23,230,22,12],[30,10,-2,2,412],[13,106,4,11,-13]],"m":5,"n":5}') {
    throw new Error('Matrix_minusEquals err');
  }
  // print(JSON.stringify(A))
  // {"A":[[705,100,-180,33,32],[-120,-30,-10,21,20],[-15,23,230,22,12],[30,10,-2,2,412],[13,106,4,11,-13]],"m":5,"n":5}
}

function minusEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 100; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.minusEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_minusEquals(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_minusEquals err');
  }

}


//A.arrayRightDivide(C)   前一个矩阵除后一个矩阵得到新矩阵   A/C
function arrayRightDivide_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[12., 32., 48, 46, 88], [60., 5., 26., 66, 70], [27., 48., 120., 30, 42], [21., 18., 60., 35, 42], [21., 72., 54., 25, 12]];
    array2 = [[24., 2., 6, 23, 44], [12., 5., 13., 3, 35], [27., 24., 60., 5, 6], [7., 3., 6., 7, 7], [3., 8., 9., 5, 2]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.arrayRightDivide(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayRightDivide: ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[0.5,16,8,2,2],[5,1,2,22,2],[1,2,2,6,7],[3,6,10,5,6],[7,9,6,5,6]],"m":5,"n":5}') {
    throw new Error('Matrix_arrayRightDivide err');
  }
  // print(JSON.stringify(B))
  // {"A":[[0.5,16,8,2,2],[5,1,2,22,2],[1,2,2,6,7],[3,6,10,5,6],[7,9,6,5,6]],"m":5,"n":5}
}

//A.arrayRightDivideEquals(C);   前一个矩阵除后一个矩阵得到新矩阵   A/C
function arrayRightDivideEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < 10000; i++) {
    array = [[10, 22, 6, 50, 30], [14., 60., 6., 72, 64], [70., 88., 90., 35, 36], [27, 48., 120, 30, 42], [21., 18., 60., 35, 42]];
    array2 = [[2., 2., 3, 5, 6], [7., 12., 6., 9, 8], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6], [7, 3, 6, 5, 7]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayRightDivideEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayRightDivideEquals(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[5,11,2,10,5],[2,5,1,8,8],[2,11,3,7,6],[1,2,2,6,7],[3,6,10,7,6]],"m":5,"n":5}') {
    throw new Error('Matrix_arrayRightDivideEquals err');
  }
  // print(JSON.stringify(A))
  //{"A":[[5,11,2,10,5],[2,5,1,8,8],[2,11,3,7,6],[1,2,2,6,7],[3,6,10,7,6]],"m":5,"n":5}
}

function arrayRightDivideEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayRightDivideEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayRightDivideEquals(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_arrayRightDivideEquals err');
  }
}

//A.arrayLeftDivide(C);  C/A   后一个矩阵除前一个矩阵
function arrayLeftDivide_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[1., 4., 3, 5, 6], [4., 5., 6., 9, 8], [7., 8., 20., 5, 6], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6]];
    array2 = [[9., 32., 39, 50, 30], [36., 40., 42., 72, 64], [49., 72., 100., 35, 36], [70., 88., 90., 35, 36], [27, 48., 120, 30, 42]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.arrayLeftDivide(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayLeftDivide: ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[9,8,13,10,5],[9,8,7,8,8],[7,9,5,7,6],[2,11,3,7,6],[1,2,2,6,7]],"m":5,"n":5}') {
    throw new Error('Matrix_arrayLeftDivide err');
  }
  // print(JSON.stringify(B))
  //{"A":[[9,8,13,10,5],[9,8,7,8,8],[7,9,5,7,6],[2,11,3,7,6],[1,2,2,6,7]],"m":5,"n":5}
}
//A.arrayLeftDivideEquals(C);  C/A   后一个矩阵除前一个矩阵
function arrayLeftDivideEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < 10000; i++) {
    array = [[2., 2., 3, 5, 6], [7., 12., 6., 9, 8], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6], [7, 3, 6, 5, 7]];
    array2 = [[10, 22, 21, 50, 30], [14., 60., 6., 72, 64], [70., 88., 90., 35, 36], [27, 48., 120, 30, 42], [21., 18., 60., 35, 42]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayLeftDivideEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayLeftDivideEquals(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[5,11,7,10,5],[2,5,1,8,8],[2,11,3,7,6],[1,2,2,6,7],[3,6,10,7,6]],"m":5,"n":5}') {
    throw new Error('Matrix_arrayLeftDivideEquals  err');
  }
  // print(JSON.stringify(A))
  // {"A":[[5,11,7,10,5],[2,5,1,8,8],[2,11,3,7,6],[1,2,2,6,7],[3,6,10,7,6]],"m":5,"n":5}
}

function arrayLeftDivideEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayLeftDivideEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayLeftDivideEquals(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_arrayLeftDivideEquals  err');
  }
}
//A.times$double(2)即矩阵扩大2倍
function times$double_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[11., 32., 43, 34, 54], [24., 51., 46, 54, 55], [27., 18., 16, 43, 44], [10, 22, 21, 50, 30], [14., 60., 6., 72, 64]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.times$double(2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times$double(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[22,64,86,68,108],[48,102,92,108,110],[54,36,32,86,88],[20,44,42,100,60],[28,120,12,144,128]],"m":5,"n":5}') {
    throw new Error('Matrix_times$double err');
  }
  // print(JSON.stringify(B));
  // {"A":[[22,64,86,68,108],[48,102,92,108,110],[54,36,32,86,88],[20,44,42,100,60],[28,120,12,144,128]],"m":5,"n":5}
}

function times$double_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.times$double(2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times$double(100*100): ${ave} ms`);
  if (B.m !== 100 || B.n !== 100) {
    throw new Error('Matrix_times$double err');
  }
}
//A.timesEquals(2);即A矩阵扩大2倍
function timesEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 10000; i++) {
    array = [[11., 32., 23, 32, 12], [24., 65., 36., 3, 23], [17., 58., 15., 34, 16], [11., 32., 43, 34, 54], [24., 51., 46, 54, 55]];
    A = new Matrix(array);
    let s = Date.now();
    A.timesEquals(2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_timesEquals(5*5): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[22,64,46,64,24],[48,130,72,6,46],[34,116,30,68,32],[22,64,86,68,108],[48,102,92,108,110]],"m":5,"n":5}') {
    throw new Error('Matrix_timesEquals err');
  }
  // print(JSON.stringify(A))
  // {"A":[[22,64,46,64,24],[48,130,72,6,46],[34,116,30,68,32],[22,64,86,68,108],[48,102,92,108,110]],"m":5,"n":5}
}
function timesEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    A.timesEquals(2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_timesEquals(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_timesEquals err');
  }
}
// A.times$Jama_Matrix(C)   A的第一列 *C的第一列之和为新矩阵[0][0]
function times$Jama_Matrix_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[121., 22., 3, 24, 67], [34., 53., 63, 56, 23], [73, 8., 10., 45, 27], [11., 32., 23, 32, 12], [24., 65., 36., 3, 23]];
    array2 = [[212., 20., 113, 34, 23], [43., 532., 36, 54, 44], [7., 8., 10, 54, 32], [17., 58., 15., 34, 16], [11., 32., 43, 34, 54]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.times$Jama_Matrix(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times$Jama_Matrix(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[27764,17684,17736,8558,7849],[11133,33364,8209,10106,7268],[16952,9270,10473,5902,4529],[4545,19668,3621,4840,3557],[8439,36258,6446,7154,5854]],"m":5,"n":5}') {
    throw new Error('Matrix_times$Jama_Matrix err');
  }
  // print(JSON.stringify(B))
  // {"A":[[27764,17684,17736,8558,7849],[11133,33364,8209,10106,7268],[16952,9270,10473,5902,4529],[4545,19668,3621,4840,3557],[8439,36258,6446,7154,5854]],"m":5,"n":5}
}
function times$Jama_Matrix_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 10; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.times$Jama_Matrix(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times$Jama_Matrix(100*100): ${ave} ms`);
  if (A.m !== B.m || A.n !== B.n) {
    throw new Error('Matrix_times$Jama_Matrix err');
  }
  // print(JSON.stringify(B))
  // {"A":[[27764,17684,17736,8558,7849],[11133,33364,8209,10106,7268],[16952,9270,10473,5902,4529],[4545,19668,3621,4840,3557],[8439,36258,6446,7154,5854]],"m":5,"n":5}
}
// A.times(C)   A的第一列 *C的第一列之和为新矩阵[0][0]
function times_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[451., 112., 133., 32, 55], [4., 45., 56, 34, 56], [4., 15., 6., 54, 7], [34., 53., 63, 56, 23], [73, 8., 10., 45, 27]];
    array2 = [[2., 782., 13, 2, 34], [314., 55., 13., 43, 31], [4., 25., 6., 53, 13], [43., 532., 36, 54, 44], [7., 8., 10, 54, 32]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.times(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[38363,379631,9819,17465,23703],[16216,25539,2757,9771,5547],[7113,32887,2297,4265,3279],[19531,61054,3755,9952,6818],[4822,81932,3003,4908,5704]],"m":5,"n":5}') {
    throw new Error('Matrix_times err');
  }
  // print(JSON.stringify(B))
  //{"A":[[38363,379631,9819,17465,23703],[16216,25539,2757,9771,5547],[7113,32887,2297,4265,3279],[19531,61054,3755,9952,6818],[4822,81932,3003,4908,5704]],"m":5,"n":5}
}

function times_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.times(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_times(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_times err');
  }
  // print(JSON.stringify(B))
  //{"A":[[38363,379631,9819,17465,23703],[16216,25539,2757,9771,5547],[7113,32887,2297,4265,3279],[19531,61054,3755,9952,6818],[4822,81932,3003,4908,5704]],"m":5,"n":5}
}

//通过new Matrix(3-0+1,[0,2].length)先生成矩阵，通过循环push值
function getMatrix$int$int$int_A_test() {
  let array2;
  let D;
  let sumAve = 0
  array2 = [[14., 0., 53, 24, 54], [4., 12., 6., 3, 24], [1, 2, 36, 54, 73], [62., 782., 83, 2, 34], [314., 55., 13., 43, 31]];
  let C = new Matrix(array2);
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    D = C.getMatrix$int$int$int_A(0, 3, [0, 2])
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int$int$int_A(5*5): ${ave} ms`);
  if (JSON.stringify(D) !== '{"A":[[14,53],[4,6],[1,36],[62,83]],"m":4,"n":2}') {
    throw new Error('Matrix_getMatrix$int$int$int_A err');
  }
  // print(JSON.stringify(D))//{"A":[[14,53],[4,6],[1,36],[62,83]],"m":4,"n":2}
}

function getMatrix$int$int$int_A_test_01() {
  let D;
  let sumAve = 0
  let array = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  let C = new Matrix(array);
  for (let i = 0; i < 10000; i++) {
    let s = Date.now();
    D = C.getMatrix$int$int$int_A(0, 3, [0, 2])
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int$int$int_A(100*100): ${ave} ms`);
  if (D.m !== 4 || D.n !== 2) {
    throw new Error('Matrix_getMatrix$int$int$int_A err');
  }
  // print(JSON.stringify(D))//{"A":[[14,53],[4,6],[1,36],[62,83]],"m":4,"n":2}
}

function getMatrix$int_A$int$int_test() {
  let array;
  let D;
  let sumAve = 0
  array = [[64., 30., 43, 74, 54], [14., 12., 46., 73, 24], [1, 42, 36, 4, 73], [62., 82., 82, 52, 34], [314., 55., 13., 43, 31]];
  let C = new Matrix(array);
  for (let i = 0; i < 10000; i++) {
    let s = Date.now();
    D = C.getMatrix$int_A$int$int([1, 4], 0, 3)
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int_A$int$int(5*5): ${ave} ms`);
  if (D.m !== 2) {
    throw new Error('Matrix_getMatrix$int_A$int$int err');
  }
  // print(JSON.stringify(D))//{"A":[[14,12,46,73],[314,55,13,43]],"m":2,"n":4}
}
function getMatrix$int_A$int$int_test_01() {
  let array = []
  for (let i = 0; i < 10; i++) {
    let arr = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  let D;
  let sumAve = 0
  let C = new Matrix(array);
  for (let i = 0; i < 1000; i++) {
    let s = Date.now();
    D = C.getMatrix$int_A$int$int([1, 4], 0, 3)
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix$int_A$int$int(100*100): ${ave} ms`);
  if (D.m !== 2) {
    throw new Error('Matrix_getMatrix$int_A$int$int err');
  }
  // print(JSON.stringify(D))//{"A":[[14,12,46,73],[314,55,13,43]],"m":2,"n":4}
}

//两个矩阵相乘
function arrayTimes_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[51., 12., 33., 32, 25], [4., 45., 56, 34, 56], [4., 15., 6., 54, 7], [34., 53., 63, 56, 23], [73, 8., 10., 45, 27]];
    array2 = [[2., 72., 13, 2, 34], [314., 55., 13., 43, 31], [4., 25., 6., 53, 13], [43., 2., 16, 54, 44], [7., 8., 10, 54, 32]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.arrayTimes(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayTimes(5*5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[102,864,429,64,850],[1256,2475,728,1462,1736],[16,375,36,2862,91],[1462,106,1008,3024,1012],[511,64,100,2430,864]],"m":5,"n":5}') {
    throw new Error('Matrix_arrayTimes err');
  }
  // print(JSON.stringify(B))
  // {"A":[[102,864,429,64,850],[1256,2475,728,1462,1736],[16,375,36,2862,91],[1462,106,1008,3024,1012],[511,64,100,2430,864]],"m":5,"n":5}
}

function arrayTimes_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 100; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.arrayTimes(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayTimes(100*100): ${ave} ms`);
  if (A.m !== 100 || A.n !== 100) {
    throw new Error('Matrix_arrayTimes err');
  }
}
//两个矩阵相乘
function arrayTimesEquals_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < 10000; i++) {
    array = [[2., 2., 3, 5, 6], [7., 12., 6., 9, 8], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6], [7, 3, 6, 5, 7]];
    array2 = [[10, 22, 21, 50, 30], [14., 60., 6., 72, 64], [70., 88., 90., 35, 36], [27, 48., 120, 30, 42], [21., 18., 60., 35, 42]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayTimesEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayTimesEquals(5*5): ${ave} ms`);
  if (A.n !== 5) {
    throw new Error('Matrix_arrayTimesEquals err');
  }
  // print(JSON.stringify(A))
  // {"A":[[20,44,63,250,180],[98,720,36,648,512],[2450,704,2700,175,216],[729,1152,7200,150,252],[147,54,360,175,294]],"m":5,"n":5}
}

function arrayTimesEquals_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = []
  let array2 = []
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < count1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    A.arrayTimesEquals(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_arrayTimesEquals(100*100): ${ave} ms`);
  if (A.n !== 100) {
    throw new Error('Matrix_arrayTimesEquals err');
  }
}

function lu_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    array = [[14., 0., 53, 24, 54], [4., 12., 6., 3, 24], [1, 2, 36, 54, 73], [62., 782., 83, 2, 34], [314., 55., 13., 43, 31]];
    A = new Matrix(array);
    B = A.lu();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_lu(5 * 5): ${ave} ms`);
  if (B.n !== 5) {
    throw new Error('Matrix_lu(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"LU":[[314,55,13,43,31],[0.19745222929936308,771.140127388535,80.43312101910828,-6.490445859872612,27.878980891719745],[0.044585987261146494,-0.0031800047906565673,52.67615987577332,22.062162898842807,52.70648968769875],[0.0031847133757961785,0.002366419149410667,0.6790217877051172,38.897727147998026,37.046445679699566],[0.012738853503184714,0.014652801295129225,0.0883857968310218,0.015356955509553004,17.969164666780692]],"m":5,"n":5,"pivsign":1,"piv":[4,3,0,2,1]}

}

function lu_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    let s = Date.now();
    A = new Matrix(array);
    B = A.lu();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_lu(100 * 100): ${ave} ms`);
  if (B.n !== 100) {
    throw new Error('Matrix_lu(100 * 100) err');
  }
}

function qr_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    array = [[2., 2., 3, 5, 6], [7., 12., 6., 9, 8], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6], [7, 3, 6, 5, 7]];
    array2 = [[10, 22, 21, 50, 30], [14., 60., 6., 72, 64], [70., 88., 90., 35, 36], [27, 48., 120, 30, 42], [21., 18., 60., 35, 42]];
    C = new Matrix(array2);
    A = new Matrix(array);
    B = A.qr();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_qr(5 * 5): ${ave} ms`);
  if (B.m !== 5 || B.n !== 5) {
    throw new Error('Matrix_qr(5 * 5) err');
  }
  // print(JSON.stringify(B))
  // {"QR":[[1.044108109139123,-22.870054588635323,-60.86919061198986,-9.218594810076725,-10.784432684515597],[0.1543783819869308,1.5028346296043136,-23.195019576973873,-4.964442262069788,-4.4925407912302155],[0.7718919099346541,-0.6274876060976277,1.4879774684386613,-6.923740112789136,-6.127650091985837],[0.5954594733781616,0.5930789624226975,-0.8584244150051611,1.8507152238030753,6.786741394827967],[0.1543783819869308,-0.04091434707016254,0.1580680676773218,-0.5256268714493993,2]],"m":5,"n":5,"Rdiag":[-45.34313619501854,-16.55175528796993,18.382945929992946,4.840831086162432,-0.9513855696818299]}

}

function qr_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }

  for (let i = 0; i < 1; i++) {
    let s = Date.now();
    C = new Matrix(array2);
    A = new Matrix(array);
    B = A.qr();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_qr(100 * 100): ${ave} ms`);
  if (B.m !== 100 || B.n !== 100) {
    throw new Error('Matrix_qr(100 * 100) err');
  }
}

function chol_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    array = [[14., 10., 13, 24, 54], [4., 12., 6., 3, 24], [1, 2, 36, 54, 73], [62., 82., 83, 2, 34], [34., 55., 13., 43, 31]];
    A = new Matrix(array);
    B = A.chol();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_chol(5 * 5): ${ave} ms`);
  if (B.isspd !== false) {
    throw new Error('Matrix_chol(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"L":[[3.7416573867739413,0,0,0,0],[1.0690449676496976,3.295017884191656,0,0,0],[0.2672612419124244,0.5202659817144719,5.971423175160349,0,0],[16.570196998570314,19.5099743142927,11.45808136931137,0,0],[9.086882225022428,13.743693016957302,0.5729040684655687,null,0]],"n":5,"isspd":false}
}

function chol_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < count1; i++) {
    let s = Date.now();
    A = new Matrix(array);
    B = A.chol();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_chol(100 * 100): ${ave} ms`);
  if (B.isspd !== false) {
    throw new Error('Matrix_chol(100 * 100) err');
  }
}

function svd_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[2., 12., 23, 35, 16], [7., 12., 6., 9, 8], [35., 8., 30, 5, 6], [27, 24., 60, 5, 6], [7, 3, 6, 5, 7]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.svd();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_svd: ${ave} ms`);
  if (B.m !== 5) {
    throw new Error('Matrix_svd err');
  }
  // print(JSON.stringify(B))
  // {"U":[[0.374074742000677,0.8737386192190489,0.0029503467821220164,-0.2986899223245987,0.0861657614015392],[0.16812507998538784,0.2139835278838194,0.21421491328005264,0.9073555947148981,0.2382494552822638],[0.4853875615915887,-0.3151413686893404,0.7491952586363833,-0.2468505964583877,0.20701710136527716],[0.7621682512524321,-0.28953197160040244,-0.5686099370030991,0.08067491576837461,-0.0737908646858849],[0.12369525743542088,0.08745873450592209,0.26361424536693516,0.14158564911460198,-0.9420782805324758]],"V":[[0.44649008488652888,-0.41263833056837884,0.7755449920266996,0.031514264633466835,0.16707192675814478],[0.3214160256598171,0.1058493264474866,-0.23213062094021296,0.854362415691324,0.3188540355956908],[0.7815774115975649,-0.1354798044689556,-0.4748092782065128,-0.3489872972970635,-0.15344701989874444],[0.23743914590558316,0.823656752667416,0.23190939154383164,-0.26784692282353556,0.3737489342121617],[0.17348701455482682,0.34894169226788436,0.25577240587482512,0.27484105595407576,-0.8409428170411654]],"s":[90.38946362207555,36.32657693608882,18.33558427103263,9.001025889673137,2.9853905260782376],"m":5,"n":5}
}

function eig_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  for (let i = 0; i < count; i++) {
    array = [[14., 35., 36., 32, 56], [74., 48., 410., 31, 23], [12., 38., 310., 32, 14], [54., 45., 26., 32, 54], [27., 28., 32., 32, 11]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.eig();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_eig(5 * 5): ${ave} ms`);
  if (B.getD().getArray()[0][0] !== 378.97438212833856 || B.getV().getArray()[0][0] !== 0.16766054237349612) {
    throw new Error('Matrix_eig(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"n":5,"issymmetric":false,"d":[378.97438212833856,93.69816878866772,-24.53474321444961,-24.53474321444961,-8.60306448810715],"e":[0,0,8.827488648822635,-8.827488648822635,0],"V":[[0.16766054237349612,0.5228672461478432,0.88618849560076,-1.2603693563567857,-0.5542211015007938],[0.7700344814466877,0.02440822097498313,-2.7938028167515454,1.7675371680059686,2.7105302812844774],[0.5693116207719512,-0.17176252197980168,0.21362802039533736,-0.1376096670943652,-0.13479142261732446],[0.18993066926504836,0.7583519755503326,0.3546526223734543,-0.16630043410181828,-1.4180122427083028],[0.13692136152076842,0.40595467637668784,0.99500814294839568,0.08576052526159306,-0.57343895653884]],"H":[[1,0.20829114334375716,-1.6775274653296812,1.0515644692536548,1.5697023888835833],[0,1,1.380767733420088,-0.902558175298331,-1.8355704412696738],[-2.043224407208919e-12,-3.8882327809835743e-16,-2.243101182787471,1.3587739269225863,1.7825275286631805],[1.5708853738435708e-13,-1.3130509533711601e-16,0,1,-0.03473175917245975],[27,7.668399593262103e-16,-2.363386870350039e-9,-9.15176433532276e-17,1]],"ort":[0,170.2548700066651,12,54,27],"cdivr":-1.6775274653296812,"cdivi":1.0515644692536548}
}

function eig_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.eig();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_eig(100 * 100): ${ave} ms`);
  if (typeof (B.getD().getArray()[0][0]) !== 'number' || typeof (B.getV().getArray()[0][0]) !== 'number') {
    throw new Error('Matrix_eig(100 * 100) err');
  }
}

function solve_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    array = [[15., 12., 76, 3, 53], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310], [43, 45, 32, 56, 76], [27., 38., 50., 32, 56]];
    array2 = [[32., 333, 89, 34, 20], [40., 432., 1., 5, 23], [32., 23., 11., 42, 56], [16, 42, 37, 23, 32], [45., 25., 86., 21, 36]];
    C = new Matrix(array2);
    A = new Matrix(array);
    B = A.solve(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_solve(5 * 5): ${ave} ms`);
  if (B.m !== 5) {
    throw new Error('Matrix_solve(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"A":[[-2.9285383387023085,38.295843411097664,-5.877203662195773,0.3848270078054076,-1.6352463633341228],[2.2191550577121197,-11.961560039233975,1.9453948522148257,-0.7051943524410685,0.9677206067714261],[0.28651206708830536,5.1811910441275035,1.4644508836051862,0.5293969739514905,0.17010983632116264],[-0.12709525492983126,-10.197930017302328,1.8250102040283596,0.5092602091158454,0.4770588635962039],[0.5265015670578769,-8.699540754668691,0.6988682818920651,-0.09569855727262465,0.3501230946709011]],"m":5,"n":5}
}

function solve_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }

  for (let i = 0; i < 1; i++) {
    let s = Date.now();
    C = new Matrix(array2);
    A = new Matrix(array);
    B = A.solve(C);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_solve(100 * 100): ${ave} ms`);
  if (B.m !== 100) {
    throw new Error('Matrix_solve(100 * 100) err');
  }
}

function solveTranspose_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  let array2;
  for (let i = 0; i < count; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    array2 = [[2., 32., 3, 54, 11], [41., 52., 36, 46, 7], [73, 38., 910, 54, 89], [40., 432., 1., 5, 23], [32., 23., 11., 42, 56]];
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.solveTranspose(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_solveTranspose(5 * 5): ${ave} ms`);
  if (B.m !== 5) {
    throw new Error('Matrix_solveTranspose(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"A":[[1.9196822547076589,3.5186144022241037,-126.78400942940497,0.21752307833083156,4.6920380003078845],[-0.93560759953717584,-1.2081435525906243,62.25759385541914,-4.567261143131207,-1.9035558707988554],[0.8350089386007655,-0.22243243153761158,17.555246555571177,3.499896902893825,-0.43140489397224512],[0.044626720370117265,1.2442880903449516,-7.177457745240792,7.557257996277996,0.4209419236930095],[-0.27746649341271768,-0.7267064090391884,16.87099898346109,-1.3293492857740916,-0.520495420286444]],"m":5,"n":5}
}

function solveTranspose_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    let arr1 = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
      arr1.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
    array2.push(arr1)
  }
  for (let i = 0; i < 1; i++) {
    C = new Matrix(array2);
    A = new Matrix(array);
    let s = Date.now();
    B = A.solveTranspose(C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_solveTranspose(100 * 100): ${ave} ms`);
  if (B.m !== 100) {
    throw new Error('Matrix_solveTranspose(100 * 100) err');
  }
}

function inverse_test() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array;
  for (let i = 0; i < 1000; i++) {
    array = [[113., 23., 34, 53, 42], [14., 25., 116, 29, 87], [47., 83., 103, 35, 56], [41., 52., 36, 46, 7], [73, 38., 91, 54, 89]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.inverse();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_inverse(5 * 5): ${ave} ms`);
  if (B.m !== 5 || B.n !== 5) {
    throw new Error('Matrix_inverse(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"A":[[0.021134834180463868,0.004582980799578046,0.008693551673787029,-0.011530718987503739,-0.019016923887217076],[-0.01974338481270728,-0.02921235122109967,0.015947040215170065,-0.00402103842527674,0.028155165565132485],[0.0252830114539571,0.03752967517693017,0.0016666460960754047,0.004677223494100485,-0.05003416817188819],[-0.012137232375558216,0.0044952115441822225,-0.02721195777705627,0.03517673118527662,0.015688908681436024],[-0.027392559172145378,-0.03238685524105501,0.0008670126388231592,-0.014950886244042616,0.05645221783298981]],"m":5,"n":5}
}

function inverse_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let C;
  let array = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 1; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.inverse();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_inverse(100 * 100): ${ave} ms`);
  if (B.m !== 100 || B.n !== 100) {
    throw new Error('Matrix_inverse(100 * 100) err');
  }
}

function det_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 1000; i++) {
    array = [[28, 32, 13, 54, 11], [41., 52., 32, 46, 7], [23, 38., 54, 54, 89], [70., 42., 1., 5, 23], [32., 23., 11., 42, 56]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.det();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_det(5 * 5): ${ave} ms`);
  if (JSON.stringify(B) !== '-6553924.000000021') {
    throw new Error('Matrix_det(5 * 5) err');
  }
}

function det_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 100; i++) {
    let arr = []
    for (let j = 0; j < 100; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }
  for (let i = 0; i < 10; i++) {
    let s = Date.now();
    A = new Matrix(array);
    B = A.det();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_det(100 * 100): ${ave} ms`);
  if (typeof (B) !== 'number') {
    throw new Error('Matrix_det(100 * 100) err');
  }
}

function rank_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 100; i++) {
    array = [[112., 52., 53, 34, 87], [7, 38., 310, 45, 32], [41, 52, 52, 46, 7], [23, 67, 24, 54, 89], [27, 13, 14, 5, 23]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.rank();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_rank: ${ave} ms`);
  if (B !== 5) {
    throw new Error('Matrix_rank  err');
  }
}

function cond_test() {
  let sumAve = 0;
  let A;
  let B;
  let array;
  for (let i = 0; i < 100; i++) {
    array = [[20, 78, 89, 43, 23], [4., 56., 586, 6, 87], [234., 63, 10, 48, 13], [41, 52, 48, 46, 7], [23, 17, 24, 54, 49]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.cond();
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_cond: ${ave} ms`);
  if (B !== 48.227961423361045) {
    throw new Error('Matrix_cond err');
  }
}

function trace_test() {
  let sumAve = 0;
  let A;
  let B;
  let array = [[12., 152., 83, 34, 37], [7, 38., 310, 45, 372], [41, 152, 52, 46, 7], [23, 627, 24, 54, 89], [27, 13, 14, 85, 23]];
  for (let i = 0; i < 15000; i++) {
    A = new Matrix(array);
    let s = Date.now();
    B = A.trace();
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_trace: ${ave} ms`);
  if (B !== 179) {
    throw new Error('Matrix_trace err');
  }
  // print(JSON.stringify(B))//179
}

function random_test() {
  let sumAve = 0;
  let A;
  let B;
  for (let i = 0; i < 2000; i++) {
    A = new Matrix(5, 5);
    let s = Date.now();
    B = Matrix.random(5, 5);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_random(5 * 5): ${ave} ms`);
  if (B.m !== 5) {
    throw new Error('Matrix_random(5 * 5) err');
  }
  // print(JSON.stringify(A))//{"A":[[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]],"m":5,"n":5}
  // print(JSON.stringify(B))
}

function random_test_01() {
  let sumAve = 0;
  let A;
  let B;
  for (let i = 0; i < 10; i++) {
    A = new Matrix(100, 100);
    let s = Date.now();
    B = Matrix.random(100, 100);
    let e = Date.now();
    sumAve += (e - s);
  }

  let ave = sumAve;
  print(`Matrix_random(100 * 100): ${ave} ms`);
  if (B.m !== 100) {
    throw new Error('Matrix_random(100 * 100) err');
  }
}

function identity_test() {
  let sumAve = 0;
  let B;
  for (let i = 0; i < count; i++) {
    let s = Date.now();
    B = Matrix.identity(5, 5);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_identity(5 * 5): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[1,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1]],"m":5,"n":5}') {
    throw new Error('Matrix_identity(5 * 5) err');
  }
  // print(JSON.stringify(B))
  //{"A":[[1,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1]],"m":5,"n":5}
}

function identity_test_01() {
  let sumAve = 0;
  let B;
  for (let i = 0; i < 100; i++) {
    let s = Date.now();
    B = Matrix.identity(100, 100);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_identity(100 * 100): ${ave} ms`);
  if (B.m !== 100) {
    throw new Error('Matrix_identity(100 * 100) err');
  }
}

function get_test() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 10000; i++) {
    let s = Date.now();
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    B = A.get(1, 1);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_get(5 * 5): ${ave} ms`);
  if (B !== array[1][1]) {
    throw new Error('Matrix_get(5 * 5) err');
  }
  // print(JSON.stringify(B))//5
  // print(B == array[1][1])
}

function get_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 10; i++) {
    let arr = []
    for (let j = 0; j < 10; j++) {
      arr.push((Math.random() * 10).toFixed())
    }
    array.push(arr)
  }

  for (let i = 0; i < count3; i++) {
    let s = Date.now();
    A = new Matrix(array);
    B = A.get(1, 1);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_get(100 * 100): ${ave} ms`);
  if (B !== array[1][1]) {
    throw new Error('Matrix_get(100 * 100) err');
  }
}


function getMatrix_test_01() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < 10000; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix(0, 3, 0, 2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix(i0:number,i1:number,j0:number,j1:number): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[31,12,35],[41,5,63],[7,34,19],[43,55,43]],"m":4,"n":3}') {
    throw new Error('Matrix_getMatrix err');
  }
  // print(JSON.stringify(B))//5
}
function getMatrix_test_02() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < count; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix([0, 3], [0, 2]);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix(s1:Array,s2:Array): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[31,35],[43,43]],"m":2,"n":2}') {
    throw new Error('Matrix_getMatrix err');
  }
  // print(JSON.stringify(B))//5
}
function getMatrix_test_03() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < count; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix(0, 1, [0, 3]);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix(i0:number,i1:number,s1:Array): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[31,42],[41,56]],"m":2,"n":2}') {
    throw new Error('Matrix_getMatrix err');
  }
  // print(JSON.stringify(B))//
}
function getMatrix_test_04() {
  let sumAve = 0;
  let A;
  let B;
  let array = [];
  for (let i = 0; i < count; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    let s = Date.now();
    B = A.getMatrix([0, 3], 0, 2);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_getMatrix(s1:Array,i0:number,i1:number): ${ave} ms`);
  if (JSON.stringify(B) !== '{"A":[[31,12,35],[43,55,43]],"m":2,"n":3}') {
    throw new Error('Matrix_getMatrix err');
  }
  // print(JSON.stringify(B))//
}
function setMatrix_test_01() {
  let sumAve = 0;
  let A;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 10000; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    array2 = [[20, 78, 89, 43, 23], [4., 56., 586, 6, 87], [234., 63, 10, 48, 13], [41, 52, 48, 46, 7], [23, 17, 24, 54, 49]];
    C = new Matrix(array2)
    let s = Date.now();
    A.setMatrix(0, 3, 1, 4, C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix(i0:number,i1:number,j0:number,j1:number,X:Matrix): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[31,20,78,89,43],[41,4,56,586,6],[7,234,63,10,48],[43,41,52,48,46],[97,62,83,67,310]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix err');
  }
  // print(JSON.stringify(A),A)//
}

function setMatrix_test_02() {
  let sumAve = 0;
  let A;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < count2; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    array2 = [[20, 78, 89, 43, 23], [4., 56., 586, 6, 87], [234., 63, 10, 48, 13], [41, 52, 48, 46, 7], [23, 17, 24, 54, 49]];
    C = new Matrix(array2)
    let s = Date.now();
    A.setMatrix(0, 2, [1, 2], C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix(i0:number,i1:number,s1:Array,X:Matrix): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[31,20,78,42,55],[41,4,56,56,31],[7,234,63,52,21],[43,55,43,21,65],[97,62,83,67,310]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix err');
  }
  // print(JSON.stringify(A),A)//
}

function setMatrix_test_03() {
  let sumAve = 0;
  let A;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < 15000; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    array2 = [[20, 78, 89, 43, 23], [4., 56., 586, 6, 87], [234., 63, 10, 48, 13], [41, 52, 48, 46, 7], [23, 17, 24, 54, 49]];
    C = new Matrix(array2)
    let s = Date.now();
    A.setMatrix([0, 2], 1, 4, C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix(s1:Array,i0:number,i1:number,X:Matrix): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[31,20,78,89,43],[41,5,63,56,31],[7,4,56,586,6],[43,55,43,21,65],[97,62,83,67,310]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix err');
  }
  // print(JSON.stringify(A),A)//
}

function setMatrix_test_04() {
  let sumAve = 0;
  let A;
  let C;
  let array = [];
  let array2 = [];
  for (let i = 0; i < count2; i++) {
    array = [[31., 12., 35, 42, 55], [41., 5., 63, 56, 31], [7, 34, 19, 52, 21], [43., 55, 43, 21, 65.], [97., 62, 83, 67, 310]];
    A = new Matrix(array);
    array2 = [[20, 78, 89, 43, 23], [4., 56., 586, 6, 87], [234., 63, 10, 48, 13], [41, 52, 48, 46, 7], [23, 17, 24, 54, 49]];
    C = new Matrix(array2)
    let s = Date.now();
    A.setMatrix([0, 2], [1, 4], C);
    let e = Date.now();
    sumAve += (e - s);
  }
  let ave = sumAve;
  print(`Matrix_setMatrix(s1:Array,s2:Array,X:Matrix): ${ave} ms`);
  if (JSON.stringify(A) !== '{"A":[[31,20,35,42,78],[41,5,63,56,31],[7,4,19,52,56],[43,55,43,21,65],[97,62,83,67,310]],"m":5,"n":5}') {
    throw new Error('Matrix_setMatrix err');
  }
  // print(JSON.stringify(A),A)//
}


function main() {
  constructWithCopy_test();
  constructWithCopy_test_01()
  copy_test();
  copy_test_01()
  clone_test();
  clone_test_01()
  getArray_test();
  getArray_test_01()
  getArrayCopy_test();
  getArrayCopy_test_01()
  getColumnPackedCopy_test();
  getColumnPackedCopy_test_01()
  getRowPackedCopy_test();
  getRowPackedCopy_test_01()
  getRowDimension_test();
  getRowDimension_test_01()
  getMatrix$int$int$int$int_test();
  getMatrix$int$int$int$int_test_01()
  setMatrix$int$int$int$int$Jama_Matrix_test();
  setMatrix$int$int$int$int$Jama_Matrix_test_01()
  setMatrix$int_A$int_A$Jama_Matrix_test();
  setMatrix$int_A$int_A$Jama_Matrix_test_01()
  setMatrix$int_A$int$int$Jama_Matrix_test();
  setMatrix$int_A$int$int$Jama_Matrix_test_01()
  setMatrix$int$int$int_A$Jama_Matrix_test();
  setMatrix$int$int$int_A$Jama_Matrix_test_01()
  set_test();
  set_test_01()
  transpose_test();
  transpose_test_01()
  norm1_test();
  norm1_test_01();
  norm2_test();
  normInf_test();
  normInf_test_01()
  normF_test();
  normF_test_01()
  uminus_test();
  uminus_test_01()
  plus_test();
  plus_test_01()
  plusEquals_test();
  plusEquals_test_01()
  minus_test();
  minus_test_01()
  minusEquals_test();
  minusEquals_test_01()
  arrayRightDivide_test();
  arrayRightDivideEquals_test();
  arrayRightDivideEquals_test_01()
  arrayLeftDivide_test();
  arrayLeftDivideEquals_test();
  arrayLeftDivideEquals_test_01()
  times$double_test();
  // times$double_test_01()
  timesEquals_test();
  timesEquals_test_01()
  times$Jama_Matrix_test();
  times$Jama_Matrix_test_01()
  times_test();
  times_test_01()
  getMatrix$int$int$int_A_test();
  getMatrix$int$int$int_A_test_01()
  getMatrix$int_A$int$int_test();
  getMatrix$int_A$int$int_test_01()
  arrayTimes_test();
  arrayTimes_test_01()
  arrayTimesEquals_test();
  arrayTimesEquals_test_01()
  lu_test();
  lu_test_01();
  qr_test();
  qr_test_01();
  chol_test();
  chol_test_01();
  svd_test();
  eig_test();
  eig_test_01();
  solve_test();
  solve_test_01();
  solveTranspose_test();
  solveTranspose_test_01();
  inverse_test();
  inverse_test_01();
  det_test();
  det_test_01();
  rank_test();
  cond_test();
  trace_test();
  random_test();
  random_test_01();
  identity_test()
  identity_test_01();
  get_test();
  get_test_01();
  getMatrix_test_01();
  getMatrix_test_02();
  getMatrix_test_03();
  getMatrix_test_04();
  setMatrix_test_01();
  setMatrix_test_02();
  setMatrix_test_03();
  setMatrix_test_04();
}

let loopCountForPreheat = 1;
for (let i = 0; i < loopCountForPreheat; i++) {
    main();
}

ArkTools.waitAllJitCompileFinish();

main();
